"""
@Filename:  web_driver/util_p2p
@Author:  liukai
@Time:  2022/11/23 0023  9:23
"""
import json
import queue
import time

import webdriver_helper
from selenium.webdriver.common.by import By


def load_cookie(d):
    try:
        with open("./cookies.json", "r") as f:
            cookies = json.loads(f.read())
            for i in cookies:
                d.add_cookie(i)
        d.refresh()
    except:
        pass

def save_cookie(d):
    cookies = d.get_cookies()
    print(type(cookies))
    with open("./cookies.json", "w") as f:
        f.write(json.dumps(cookies))


def is_login(d):
    try:
        use = d.find_element(By.XPATH, "/html/body/form/table/tbody/tr/td[3]/table/tbody/tr[2]/td[2]/input")
    except Exception as e:
        return False
    if use:
        return True
    else:
        return False




if __name__ == '__main__':
    pass
